import Taro, { Component } from '@tarojs/taro'
import { AtTabBar } from 'taro-ui'

export default class MyTabBar extends Component {

  constructor () {
    super(...arguments)
    this.state = {
      current: 0
    }
  }

  handleClick (value) {
    this.setState({
      current: value
    })
    switch(value) {
      case 0:
      Taro.redirectTo({url:'/pages/index/index'})
      break;
      case 1:
      Taro.redirectTo({url:'/pages/search/index'})
      break;
      case 2:
      Taro.redirectTo({url:'/pages/requirement/add'})
      break;
    }
  }


  render () {
    return (
        <AtTabBar
          fixed
          tabList={[
            { title: '最近', iconType: 'eye', text: '100'},
            { title: '查找', iconType: 'search' },
            { title: '发布', iconType: 'add-circle' }
          ]}
          onClick={this.handleClick.bind(this)}
          current={this.state.current}
        />
    )
  }
}
